﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AircraftCarrier.Lib
{
    public class OCRHelper
    {
        public static string Process(string imgPath)
        {
            MODI.Document md = new MODI.Document();
            md.Create(imgPath);
            md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
            string strText = String.Empty;

            MODI.Image image = (MODI.Image)md.Images[0];
            MODI.Layout layout = image.Layout;

            for (int i = 0; i < layout.Words.Count; i++)
            {
                MODI.Word word = (MODI.Word)layout.Words[i];
                if (strText.Length > 0)
                {
                    strText += " ";
                }
                strText += word.Text;

            }
            md.Close(false);
            return strText;
        }
    }
}
